<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<base href="<%=basePath%>">
		<meta charset="utf-8" />
		<title></title>
		<meta name="description" content="overview & stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link href="static/css/bootstrap.min.css" rel="stylesheet" />
		<link href="static/css/bootstrap-responsive.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="static/css/font-awesome.min.css" />
		<link rel="stylesheet" href="static/css/ace.min.css" />
		<link rel="stylesheet" href="static/css/ace-responsive.min.css" />
		<link rel="stylesheet" href="static/css/ace-skins.min.css" />
		<script type="text/javascript" src="static/js/jquery-1.7.2.js"></script>

<script type="text/javascript">
	$(top.hangge());	
	
	//新增
	function addcourse(){
		 top.jzts();
		 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="新增课程";
		 diag.URL = '<%=basePath%>course/toAdd.shtml';
		 diag.Width = 223;
		 diag.Height = 256;
		 diag.CancelEvent = function(){ //关闭事件
/*			if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
				top.jzts(); 
				setTimeout("location.reload()",100);
			}*/
             setTimeout("location.reload()",100);
			diag.close();
		 };
		 diag.show();
	}
	
	//修改
	function editcourse(cId){
		 top.jzts();
	   	 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="修改课程";
		 diag.URL = '<%=basePath%>course/toEdit.shtml?cId='+cId;
		 diag.Width = 223;
		 diag.Height = 256;
		 diag.CancelEvent = function(){ //关闭事件
/*			if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
				top.jzts(); 
				setTimeout("location.reload()",100);
			}*/
             setTimeout("location.reload()",100);
			diag.close();
		 };
		 diag.show();
	}

	
	function delcourse(cId){
		var flag = false;
			if(confirm("确定要删除该课程吗？")){
				flag = true;
			}
		if(flag){
			top.jzts();
			var url = "<%=basePath%>course/del.shtml?cId="+cId+"&guid="+new Date().getTime();
			$.get(url,function(data){
				top.jzts();
				document.location.reload();
			});
		}
	}

</script>
</head>

<body>
	<table id="table_report" class="table table-striped table-bordered table-hover">
		<thead>
		<tr>
<%--			<td class='center' style="width: 30px;">${vs.index+1}</td>
			<th class="center"  style="width: 50px;">${vs.index+1}</th>--%>
			<th class="center"  style="width: 50px;">序号</th>
			<th class='center'>COURSE_ID(课程号)</th>
			<th class='center'>COURSE_NAME(课程名)</th>
			<th class='center'>USER_ID(教师工号)</th>
			<th class='center'>USERNAME(教师)</th>
			<th class='center'>操作</th>
		</tr>
		</thead>
		<c:choose>
			<c:when test="${not empty courseList}">
				<c:forEach items="${courseList}" var="course" varStatus="vs">
				<tr id="tr${course.C_ID}">
				<td class='center' style="width: 30px;">${vs.index+1}</td>
				<td>${course.COURSE_ID} </td>
				<td>${course.COURSE_NAME}</td>
				<td>${course.USER_ID}</td>
				<td>${course.USERNAME}</td>



				<td style="width: 25%;">
				<a class='btn btn-mini btn-info' title="编辑" onclick="editcourse('${course.C_ID }')" ><i class='icon-edit'></i></a>
				<a class='btn btn-mini btn-danger' title="删除"  onclick="delcourse('${course.C_ID}',true)"><i class='icon-trash'></i></a>
				</tr>
				</c:forEach>
			</c:when>
			<c:otherwise>
				<tr>
				<td colspan="100">没有相关数据</td>
				</tr>
			</c:otherwise>
		</c:choose>
	</table>
	
	<div class="page_and_btn">
		<div>
			&nbsp;&nbsp;<a class="btn btn-small btn-success" onclick="addcourse();">新增</a>
		</div>
	</div>
	
</body>
</html>